package com.xxx.base.common.region;

import java.util.Arrays;
import java.util.function.Predicate;

/**
 * Description：
 * Created by fyx on 3/30/2017.
 * Version：
 */
public enum RegionLevel {

    UNKNOWN(0), COUNTRY(1), PROVINCE(2), CITY(3), DISTRICT(4);

    private int index;

    private RegionLevel(int index) {
        this.index = index;
    }

    public static RegionLevel parseIndex(int index) {
        return Arrays.asList(RegionLevel.values()).stream().filter(new Predicate<RegionLevel>() {
            @Override
            public boolean test(RegionLevel regionLevel) {
                return regionLevel.getIndex() == index;
            }
        }).findFirst().get();
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
